import {
  IsString,
  IsNotEmpty,
  IsDate,
  IsISBN,
  IsUrl,
  IsIn,
} from 'class-validator';
import { Type } from 'class-transformer';

export class CreateBookDto {
  @IsString()
  @IsNotEmpty()
  title: string;

  @IsString()
  @IsNotEmpty()
  author: string;

  @IsString()
  @IsISBN()
  isbn: string;

  @IsString()
  @IsNotEmpty()
  description: string;

  @IsString()
  @IsUrl()
  cover: string;

  @IsString()
  @IsNotEmpty()
  publisher: string;

  @Type(() => Date)
  @IsDate()
  publishDate: Date;

  @IsString()
  @IsNotEmpty()
  category: string;
}

export class UpdateBookDto extends CreateBookDto {
  @IsString()
  @IsIn(['available', 'borrowed', 'reserved'])
  status?: 'available' | 'borrowed' | 'reserved';
}

export class CreateBookCommentDto {
  @IsString()
  @IsNotEmpty()
  content: string;
}
